<?php
$this->set('title_for_layout', $chapter['Chapter']['name']);
$this->set('description_for_layout', $chapter['Chapter']['name'] . ' to jedna z grup GDG działająca w Polsce. Zarejestruj się na jeden z naszych eventów.');
?>
<div class="chapter-page">
    <a class="right gbutton green share-button-intent hidden" data-url="<?= $this->Html->url(array(), true) ?>" href="#">Udostępnij stronę</a>
    <h1><?= $chapter['Chapter']['name'] ?></h1>

    <div class="share">
        <div class="item">
            <div class="fb-like" data-send="false" data-layout="button_count" data-width="120" data-show-faces="false" data-action="recommend"></div>
        </div>
        <div class="item">
            <div class="g-plusone" data-size="small" data-width="120" data-annotation="inline"></div>
        </div>
    </div>
    <div class="desc">
        <?= $chapter['Chapter']['desc'] ?>
    </div>

    <div class="chapter-events">
        <h3>Najbliższe wydarzenia</h3>
        <div class="regular-events">
        <?php
        if (!empty($chapter['Event'])) {
            foreach ($chapter['Event'] as $event) {
                $eventUrl = $this->Html->url(array('controller' => 'events', 'action' => 'view', 'slug' => $event['slug']));
                $accepting = true;
                if ($event['accepting'] == '0') {
                    $accepting = false;
                }
                ?> 
                <div class="event">
                    <div class="event-wrapper">
                    <a class="right gbutton blue share-button-intent hidden" data-url="<?= $this->Html->url($eventUrl, true) ?>" href="#">Udostępnij</a>
                    <?php if ($accepting): ?>
                        <a class="right gbutton blue hidden" data-eventid="<?= $event['id'] ?>" rel="nofollow" href="<?= $eventUrl ?>">Chcę tam być</a>
                            <?php endif; ?>
                    <div class="name">
                        <a href="<?= $eventUrl ?>">
        <?= $event['name'] ?>
                        </a>
                    </div>
                    <div class="clearfix"></div>
                    <div class="date"><?= $this->Timepl->niceShort($event['startdate']) ?></div>
                    </div>
                </div>
            <?php }
            ?></div><?php
        } else { ?>
            <p>Nie ma tu nic ciekawego. Ale za chwilę na pewno się pojawi :)</p>    
<?php } ?>
        <a class="right button past-events-load" data-page="1" data-chapter="<?=$chapter['Chapter']['id']?>" href="<?=$this->Html->url(array('controller'=>'events','action'=>'index','since'=>'now'),true)?>">Zobacz zakończone spotkania</a>
        <div class="clearfix"></div>
    </div>
</div>